<?php $all_session = $this->session->all_userdata(); ?>
<!DOCTYPE html>
<!-- saved from url=(0056)http://startbootstrap.com/templates/simple-sidebar.html# -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Panel</title>
<script src="<?php echo base_url();?>js/chart.js"></script>
<?php $this->load->view('panel_head');?>
</head>

<body onload="startTime()">

<script type="text/javascript">

		
          $(document).ready(function(){
            $("#check_pass").change(function(){
            $("#message").html("checking...");
             
 
            var check_pass=$("#check_pass").val();
 
              $.ajax({
                    type:"post",
                    url:"<?php echo base_url();?>index.php/pmember/check_user",
                    data:"check_pass="+check_pass+"&check_id=<?php echo $this->uri->segment(3);?>",
                        success:function(data){
                        if(data==1){
                            $("#message").html("The Password is correct".fontcolor("green"));
							document.getElementById("check_pass").style.borderColor = "green";
							document.getElementById("submit").disabled=false;
						} else {
                            $("#message").html("The Password is wrong!".fontcolor("red"));
							document.getElementById("check_pass").focus();
							document.getElementById("check_pass").style.borderColor = "#E34234";
							document.getElementById("submit").disabled=true;
                        }
						
                    }
                 });
 
            });
 
         });
		 
 
</script>

<script language="javascript">
function chk()
{	
	if(document.getElementById("mem_pass").value != document.getElementById("confirm_pass").value)
	{
		alert('Password Not Match');
		document.getElementById("mem_pass").style.borderColor = "#E34234";
		document.getElementById("confirm_pass").style.borderColor = "#E34234";
		document.getElementById("confirm_pass").focus();
		return false;
	}
	
	var fty=new Array(".gif",".jpg",".jpeg",".png"); // ประเภทไฟล์ที่อนุญาตให้อัพโหลด   
        var a=document.form1.file_1.value; //กำหนดค่าของไฟล์ใหกับตัวแปร a   
		var permiss=0; // เงื่อนไขไฟล์อนุญาต
		a=a.toLowerCase();   
		if(a !=""){
			for(i=0;i<fty.length;i++){ // วน Loop ตรวจสอบไฟล์ที่อนุญาต   
				if(a.lastIndexOf(fty[i])>=0){  // เงื่อนไขไฟล์ที่อนุญาต   
					permiss=1;
					break;
				}else{
					continue;
				}
			}  
			if(permiss==0){ 
				alert("Upload only GIF ,JPG or PNG format ");   
				document.getElementById("file_1").focus();  
				return false;   			
			} 		
		}

}
</script>


<?php $this->load->view('panel_header');?>
<div style="height:46px;"></div>
<div id="wrapper"> 
  
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <?php $this->load->view('panel_sidebar');?>
  </div>
  
  <!-- Page content -->
  <div id="page-content-wrapper">
    <div class="content-header">
      <h1><span class="glyphicon glyphicon-user"></span>&nbsp;Update Profile</h1>      
    </div>
    <!-- Keep all page content within the page-content inset div! -->
    <?php $attributes = array('onsubmit' => 'return chk()', 'id' => 'form1' ,'name' => 'form1'); ?>
    <?php echo form_open_multipart('pmember/update_member/'.@$member[0]['mem_id'].'/pmember' ,$attributes);?>
    <input type="hidden" value="<?php echo $this->uri->segment(1); ?>" name="seg1" >
    <div class="page-content inset">
      <div class="panel panel-default">
        <div class="panel-body">
          <div align="center" style="margin:1.2em 0	;">
           <?php if(@$member[0]['mem_image'] == '') { ?>
           <img data-src="holder.js/250x250">
           <?php } else { ?>
          <img src="<?php echo base_url();?>uploads/<?php echo @$member[0]['mem_image']; ?>" width="250em"></img>
          <?php } ?>
          </div>
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Username</strong></h5>
              <input type="hidden" value="<?php echo $member[0]['mem_name'];?>" name="mem_name" />
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
            <fieldset disabled>
              <input type="text" class="form-control" style="width:22em;" value="<?php echo @$member[0]['mem_name']; ?> (<?php if($member[0]['mem_type'] == 0){ echo "Member"; } else if ($member[0]['mem_type'] == 1) { echo "Moderator"; } else if($member[0]['mem_type']== 2) { echo "Administrator"; } else if($member[0]['mem_type'] == 3) { echo "Banned"; }?>)" name="mem_name">
              </fieldset>
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Role</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
             
              <select name="mem_type" class="form-control" style="width:12em;"  >
              	<option value="<?php echo $member[0]['mem_type'];?>">-- <?php if($member[0]['mem_type'] == 0){ echo "Member"; } else if ($member[0]['mem_type'] == 1) { echo "Moderator"; } else if($member[0]['mem_type']== 2) { echo "Administrator"; } else if($member[0]['mem_type'] == 3) { echo "Banned"; }?> --</option>
                <option value="2">Administrator</option>
                <option value="1">Modarator</option>
                <option value="0">Member</option>
                <option value="3">Ban</option>
              </select>
              
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>E-mail</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
                <input type="text" class="form-control" style="width:22em;" value="<?php echo @$member[0]['mem_mail']; ?>" name="mem_mail" required>
           
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>First Name</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">             
                <input type="text" class="form-control" style="width:22em;" value="<?php echo @$member[0]['mem_fname']; ?>" name="mem_fname" required>
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Last Name</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
            
                 <input type="text" class="form-control" style="width:22em;" value="<?php echo @$member[0]['mem_lname']; ?>" name="mem_lname" required>
              
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Date of Birth</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
               <input type="text" id="date" data-format="YYYY-MM-DD" data-template="D MMM YYYY" name="mem_birth" value="<?php echo @$member[0]['mem_birth'];?>"/>
              
            <script id="js-date">
				$(function(){
					$('#date').combodate();    
				});
			</script>
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
           <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Address</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">   
              <textarea name="mem_address" rows="5" class="form-control" style="width:22em;"><?php echo str_replace("<br>\n", "\n", $member[0]['mem_address']); ?></textarea>
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Telephone Number</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
               <h5>
                 <input type="tel" class="form-control" style="width:22em;" value="<?php echo @$member[0]['mem_tell']; ?>" name="mem_tell">
               </h5>
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>Profile picture</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
              <input type="file" name="userfile" size="20" id="file_1"/>
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> --> 
          
              
          <div class="row" style="margin-bottom:1.5em;" >
            <div class="col-md-4">
              <h5><strong>Old Password</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
              <input type="password" class="form-control" style="width:22em;" name="check_pass" id="check_pass"><p id="message"></p>   
           
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
             
          <div class="row" >
            <div class="col-md-4">
              <h5><strong>New Password</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
              <input type="password" class="form-control" style="width:22em;" name="mem_pass" id="mem_pass">
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          <div class="row" style="margin-bottom:1.5em;">
          	<div class="col-md-4">
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
            <font size="-2">
            If you would like to change the password type a new one. Otherwise leave this blank.
            </font>
            </div>
            <!-- <div class="col-md-8"> -->
            </div>
            <!-- <div class="row"> -->
          
             
          <div class="row" style="margin-bottom:1.5em;">
            <div class="col-md-4">
              <h5><strong>New Repeat Password</strong></h5>
            </div>
            <!-- <div class="col-md-4"> -->
            <div class="col-md-8">
              <input type="password" class="form-control" style="width:22em;" id="confirm_pass">
            </div>
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
           <div class="row">
            <div class="col-md-12" align="center">
            <button type="submit" class="btn btn-primary" name="submit" id="submit" value="1">Update Profile</button>
            </div>
            <!-- <div class="col-md-4"> -->
           
            <!-- <div class="col-md-8"> --> 
          </div>
          <!-- <div class="row"> -->
          
          
        </div>
      </div>
    </div>
  </div>
</div>

<script>
    $("#menu-toggle").click(function(e) {
        e.preventDefault();
        $("#wrapper").toggleClass("active");
    });
</script> 
</body>
</html>
